package org.canto.poss.controller;

import cn.hutool.json.JSONUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.canto.poss.domain.entity.Menu;
import org.canto.poss.service.MenuService;
import org.canto.poss.service.impl.MenuServiceImpl;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Description:
 *
 * @author jsryin
 * @date 2024/12/10 23:49
 */
@Controller
@RequestMapping(value = "/page")
public class PageController {
    private Logger logger = LogManager.getLogger(MenuServiceImpl.class);

    @Resource
    private MenuService menuService;

    @RequestMapping(value = "login")
    public String index(Model model) {
        model.addAttribute("name", "xigua");
        return "content/test/login";
    }

    @ResponseBody
    @RequestMapping(value = "menu")
    public List<Menu> menu(HttpServletRequest request) {
        List<Menu> menus = menuService.selectList(new Menu());
        System.out.println(JSONUtil.toJsonStr(menus));
        return menus;
    }

}
